#include "colors.inc"    // The include files contain
#include "stones.inc"    // pre-defined scene elements
                                                        
#include "textures.inc"    // pre-defined scene elements
#include "shapes.inc"
#include "glass.inc"
#include "metals.inc"
#include "woods.inc"   



#declare USE_CATADIOPTRIC_VIEW=1;

#declare ROAD_WIDTH = 5;
#declare ROUNADABOUT_INTERNAL_RADIUS = 3;
#declare ROUNADABOUT_RADIUS = ROUNADABOUT_INTERNAL_RADIUS + ROAD_WIDTH;
#declare ROAD_HEIGHT = 0.1;
#declare GROUND_HEIGHT = 0;
#declare DISTANCE_BETWEEN_PARALLEL_ROADS = 1;
#declare HALF_DISTANCE_BETWEEN_PARALLEL_ROADS = DISTANCE_BETWEEN_PARALLEL_ROADS/2;
#declare SCENE_EXTENT = 200;




#declare CATADIOPTRIC_MIRROR_HEIGHT = 5;
#declare CATADIOPTRIC_MIRROR_TO_CAMERA_DISTANCE = 4;
#declare CATADIOPTRIC_MIRROR_SPHERE = sphere{
   <0,0,0>,2
   finish{
     reflection {1}
     ambient 0
     diffuse 0
   }
}


#declare CATADIOPTRIC_MIRROR_PARABOLA = isosurface {
    function { sqrt(pow(x,2) + pow(y,2) + pow(z,2)) - 2 }
    contained_by { box { -2, 2 } }
   finish{
     reflection {1}
     ambient 0
     diffuse 0
   }
  }


object {CATADIOPTRIC_MIRROR_PARABOLA translate y*CATADIOPTRIC_MIRROR_HEIGHT}

#if(USE_CATADIOPTRIC_VIEW)
  camera {
    orthographic
    location <0, CATADIOPTRIC_MIRROR_HEIGHT - CATADIOPTRIC_MIRROR_TO_CAMERA_DISTANCE , 0>
    look_at  <0, CATADIOPTRIC_MIRROR_HEIGHT,  0>    
  }
#else
  camera {
    perspective
    //location <ROAD_WIDTH, ROAD_WIDTH*6, -ROAD_WIDTH*6>
    location <ROAD_WIDTH, ROAD_WIDTH*2, -ROAD_WIDTH*2>
    look_at  <0, 0,  0>
    focal_point < 0, 0, 0>   
    blur_samples 20      // more samples, higher quality image
  }  
#end





#declare LandArea = texture {
      pigment {
        agate
        turbulence 1
        lambda 1.5
        omega .8
        octaves 8
        color_map {
          [0.00 color rgb <.5, .25, .15>]
          [0.33 color rgb <.1, .5, .4>]
          [0.86 color rgb <.2, .6, .1>]
          [1.00 color rgb <.5, .25, .15>]
        }
      }
    }



#declare building1 = box{ <3,3,3>, <0,0,0>}                  
  


  plane { <0, 1, 0>, 0
    texture {LandArea}
  }



object{
building1
translate -x*(ROUNADABOUT_RADIUS + ROAD_WIDTH) - z*(ROUNADABOUT_RADIUS + ROAD_WIDTH + 2)
}



difference {
    torus {
      ROUNADABOUT_RADIUS, ROAD_WIDTH/2
    }
    box { <-SCENE_EXTENT, SCENE_EXTENT, -SCENE_EXTENT>, <SCENE_EXTENT, ROAD_HEIGHT, SCENE_EXTENT> }
    box { <-SCENE_EXTENT, -SCENE_EXTENT, -SCENE_EXTENT>, <SCENE_EXTENT, GROUND_HEIGHT, SCENE_EXTENT> }
    pigment { Gray50 }
}


#declare roads = union{

box { <-SCENE_EXTENT, ROAD_HEIGHT, ROAD_WIDTH>, <SCENE_EXTENT, GROUND_HEIGHT, HALF_DISTANCE_BETWEEN_PARALLEL_ROADS> }

box { <-SCENE_EXTENT, ROAD_HEIGHT, -HALF_DISTANCE_BETWEEN_PARALLEL_ROADS>, <SCENE_EXTENT, GROUND_HEIGHT, -ROAD_WIDTH> }

box { <ROAD_WIDTH, ROAD_HEIGHT, -SCENE_EXTENT>, <HALF_DISTANCE_BETWEEN_PARALLEL_ROADS, GROUND_HEIGHT, SCENE_EXTENT> }

box { <-HALF_DISTANCE_BETWEEN_PARALLEL_ROADS, ROAD_HEIGHT, -SCENE_EXTENT>, <-ROAD_WIDTH, GROUND_HEIGHT, SCENE_EXTENT> }

}

difference{
   object {roads}
   sphere{<0,0,0>,ROUNADABOUT_RADIUS}
   pigment { color Gray50 }
}



light_source { <2, 4, -3> color White}




    